package com.loongtech.bi.manager.client;

import com.loongtech.bi.entity.client.EntityIterativeEventAnalysis;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class IterativeEventAnalysisManager extends ManagerQueryCacheBase<EntityIterativeEventAnalysis> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 获取 EntityEventAnalysis 细节
	 * @param dateStart
	 * @param dateEnd
	 * @param queryPlatform
	 * @param queryChannel
	 * @param queryServer
	 * @return
	 */
	public List<Object[]> getIterativeEventAnalysis(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel,String queryServer) {
        return findByQuery("select stepcode,finishnum,uuidnum from EntityIterativeEventAnalysis  where 1=1 and startday = '"+ Time.getDateStr(dateStart) +"' and endday = '"+ Time.getDateStr(dateEnd) +"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+ queryServer+"' order by stepcode asc");
	}

    public List<Object[]> getIterativeEventAnalysisChannel(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel,String queryServer) {
        return findByQuery("select channelid,stepcode,max(finishnum),max(uuidnum) from EntityIterativeEventAnalysis  where 1=1 and startday = '"+ Time.getDateStr(dateStart) +"' and endday = '"+ Time.getDateStr(dateEnd) +"' and platformid = '0' and channelid != '0' and serverid = '0' group by channelid,stepcode order by stepcode asc");
    }

    public List<Object[]> getIterativeEventAnalysisByPhone(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel,String queryServer) {
	    String sql = "select devicemodel,stepcode,uuidnum from EntityIterativeEventAnalysisByPhone  where 1=1 and startday = '"+ Time.getDateStr(dateStart) +"' and endday = '"+ Time.getDateStr(dateEnd) +"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+ queryServer+"'  group by devicemodel,stepcode order by stepcode asc";
        System.out.println("output is :  " + sql);
        return findByQuery("select devicemodel,stepcode,uuidnum from EntityIterativeEventAnalysisByPhone  where 1=1 and startday = '"+ Time.getDateStr(dateStart) +"' and endday = '"+ Time.getDateStr(dateEnd) +"' and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+ queryServer+"'  group by devicemodel,stepcode order by stepcode asc");
    }
}
